package com.yyr.spring_boot.modules.test.dao;

import com.yyr.spring_boot.modules.test.entity.Student;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface StudentDao extends JpaRepository<Student, Integer> {

    List<Student> findByStudentName(String studentName);

    //nativeQuery 本地查询，用原生的sql语句查询
//    @Query(nativeQuery = true, value = "select * from test_student where id = :id")
    @Query(value = "from Student where id = :id")
    Student getStudentById(@Param("id") int id);
}
